#include<iostream>
#include<algorithm>

using namespace std;
const int N = 1e4 + 10;
int arr[N];

int main()
{
	int n; cin >> n;
	for (int i = 0; i < n; i++) cin >> arr[i];
	int k = n-1; int sum = 0;
	while (k>=0)
	{
		for (int i = 0; i <k; i++)
		{
			if (arr[i] > arr[i + 1])
			{
 				swap(arr[i], arr[i + 1]);
				sum++;
			}
		}
		k--;
	}
	cout << sum;
	return 0;
}

